// translate router.meta.title, be used in breadcrumb sidebar tagsview
import Cookies from 'js-cookie'
export function generateTitle(obj) {
  if (obj.name || obj.ename) {
    const type = Cookies.get('language') || 'zh'
    if (type === 'zh') {
      return obj.name
    } else {
      return obj.ename
    }
  } else {
    const title = obj.title
    const hasKey = this.$te('route.' + title)
    if (hasKey) {
      // $t :this method from vue-i18n, inject in @/lang/index.js
      const translatedTitle = this.$t('route.' + title)
      return translatedTitle
    }
  }
  return obj.name || obj.titlle
}
